package bpmn.camunda.plugin;

import org.camunda.bpm.engine.impl.bpmn.parser.AbstractBpmnParseListener;
import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl;
import org.camunda.bpm.engine.impl.pvm.process.ScopeImpl;
import org.camunda.bpm.engine.impl.util.xml.Element;

import java.util.List;

/**
 * BPMN Parse Listener to parse extension properties on service task
 *
 * @author kristin.polenz
 */
public class ProgressLoggingSupportParseListener extends AbstractBpmnParseListener {


    @Override
    public void parseUserTask(Element userTaskElement, ScopeImpl scope, ActivityImpl activity) {


        System.out.println(userTaskElement.elements());


        System.out.println("asdfasdf");

    }

    @Override
    public void parseServiceTask(Element serviceTaskElement, ScopeImpl scope, ActivityImpl activity) {

        System.out.println("asdfasdfasdfasdfasdfasdfasdf");


        List<Element> elements = serviceTaskElement.elements();


        Element extensionElement = serviceTaskElement.element("extensionElements");

        if (extensionElement != null) {

            Element propertiesElement = extensionElement.element("properties");

            if (propertiesElement != null) {


                List<Element> propertyList = propertiesElement.elements("property");
                for (Element property : propertyList) {
                    String name = property.attribute("name");
                    String value = property.attribute("value");


                    System.out.println("----------------------------------");
                    System.out.println("----------------------------------");
                    System.out.println("----------------------------------");
                    System.out.println("----------------------------------");
                    System.out.println("----------------------------------");
                    System.out.println("----------------------------------");
                    System.out.println("----------------------------------");

                    System.out.println(name);

                    System.out.println(value);


                }
            }
        }
    }


}
